import numpy as np
import matplotlib.pyplot as plt
import os
from matplotlib.colors import LogNorm

# define data directory
fname = 'exfig3b.npz'

# load npz file
data = np.load(fname, allow_pickle=True)
print(data.files)
#save data to variables
for key in data.files:
    exec(key + " = data['" + key + "']")

# plot
fig, ax = plt.subplots(1, 1, figsize=(7, 6))
fig.suptitle('exfig3b')
im = ax.scatter(n, D, c=delta_R/1e3, rasterized=True, vmin=-0.1,vmax=0.5, cmap='viridis',marker='s',s=1) 
# add colorbar
cbar = fig.colorbar(im, ax=ax)
cbar.set_label(r'$\Delta R$ (k$\Omega$)')
ax.set_xlabel('n (10$^{12}$ cm$^{-2}$)')
ax.set_ylabel(r'$D/\epsilon_0$ (V/nm)')
plt.show()